import Vue from 'vue'
import Router from 'vue-router'
import common from './Common.vue'

Vue.use(Router)

// 解决重复导航路由报错
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'common',
      component: common,
      redirect: '/introduce' ,
      children: [
        {
          path: '/introduce',
          name: 'introduce',
          component: () => import(/* webpackChunkName: "introduce" */ './views/docs/Introduce.vue')
        },
        {
          path: '/install',
          name: 'install',
          component: () => import(/* webpackChunkName: "introduce" */ './views/docs/Install.vue')
        },
        {
          path: '/quickStart',
          name: 'quickStart',
          component: () => import(/* webpackChunkName: "introduce" */ './views/docs/QuickStart.vue')
        },
        {
          path: '/language',
          name: 'language',
          component: () => import(/* webpackChunkName: "introduce" */ './views/docs/Language.vue')
        },
        {
          path: '/custom',
          name: 'custom',
          component: () => import(/* webpackChunkName: "introduce" */ './views/docs/Custom.vue')
        },
        {
          path: '/docs',
          name: 'docs',
          component: () => import(/* webpackChunkName: "docs" */ './views/docs/Docs.vue')
        },
        {
          path: '/icon',
          name: 'icon',
          component: () => import(/* webpackChunkName: "icon" */ './views/icon/Icon.vue')
        },
        {
          path: '/button',
          name: 'button',
          component: () => import(/* webpackChunkName: "button" */ './views/button/Button.vue')
        },
        {
          path: '/input',
          name: 'input',
          component: () => import(/* webpackChunkName: "input" */ './views/input/Input.vue')
        },
        {
          path: '/inputNumber',
          name: 'inputNumber',
          component: () => import(/* webpackChunkName: "input" */ './views/inputNumber/InputNumber.vue')
        },
        {
          path: '/page',
          name: 'page',
          component: () => import(/* webpackChunkName: "input" */ './views/page/Page.vue')
        },
        {
          path: '/layout',
          name: 'layout',
          component: () => import(/* webpackChunkName: "layout" */ './views/layout/Layout.vue')
        },
        {
          path: '/grid',
          name: 'grid',
          component: () => import(/* webpackChunkName: "Grid" */ './views/grid/Grid.vue')
        },
        {
          path: '/tabs',
          name: 'tabs',
          component: () => import(/* webpackChunkName: "tabs" */ './views/tabs/Tabs.vue')
        },
        {
          path: '/tree',
          name: 'tree',
          component: () => import(/* webpackChunkName: "Tree" */ './views/tree/Tree.vue')
        },
        {
          path: '/model',
          name: 'model',
          component: () => import(/* webpackChunkName: "model" */ './views/model/Model.vue')
        },
        {
          path: '/checkbox',
          name: 'checkbox',
          component: () => import(/* webpackChunkName: "checkBox" */ './views/checkBox/Checkbox.vue')
        },
        {
          path: '/radio',
          name: 'radio',
          component: () => import(/* webpackChunkName: "radio" */ './views/radio/Radio.vue')
        },
        {
          path: '/form',
          name: 'form',
          component: () => import(/* webpackChunkName: "Form" */ './views/form/Form.vue')
        },
        {
          path: '/table',
          name: 'table',
          component: () => import(/* webpackChunkName: "table" */ './views/table/Table.vue')
        },
        {
          path: '/select',
          name: 'select',
          component: () => import(/* webpackChunkName: "select" */ './views/select/Select.vue')
        },
        {
          path: '/cascader',
          name: 'cascader',
          component: () => import(/* webpackChunkName: "cascader" */ './views/cascader/Cascader.vue')
        },
        {
          path: '/cascaderEasy',
          name: 'cascaderEasy',
          component: () => import(/* webpackChunkName: "cascaderEasy" */ './views/cascaderEasy/CascaderEasy.vue')
        },
        {
          path: '/loading',
          name: 'loading',
          component: () => import(/* webpackChunkName: "loading" */ './views/loading/Loading.vue')
        },
        {
          path: '/switch',
          name: 'switch',
          component: () => import(/* webpackChunkName: "table" */ './views/switch/Switch.vue')
        },
        {
          path: '/breadcrumb',
          name: 'breadcrumb',
          component: () => import(/* webpackChunkName: "table" */ './views/breadcrumb/Breadcrumb.vue')
        },
        {
          path: '/alert',
          name: 'alert',
          component: () => import(/* webpackChunkName: "alert" */ './views/alert/Alert.vue')
        },
        {
          path: '/tag',
          name: 'tag',
          component: () => import(/* webpackChunkName: "tag" */ './views/tag/Tag.vue')
        },
        {
          path: '/message',
          name: 'message',
          component: () => import(/* webpackChunkName: "message" */ './views/message/Message.vue')
        },
        {
          path: '/notification',
          name: 'notification',
          component: () => import(/* webpackChunkName: "message" */ './views/notice/Notice.vue')
        },
        {
          path: '/information',
          name: 'information',
          component: () => import(/* webpackChunkName: "information" */ './views/information/information.vue')
        },
        {
          path: '/datePicker',
          name: 'datePicker',
          component: () => import(/* webpackChunkName: "datePicker" */ './views/datePicker/DatePicker.vue')
        },
        {
          path: '/timePicker',
          name: 'timePicker',
          component: () => import(/* webpackChunkName: "timePicker" */ './views/timePicker/TimePicker.vue')
        },
        {
          path: '/uplode',
          name: 'uplode',
          component: () => import(/* webpackChunkName: "uplode" */'./views/upload/Upload.vue')
        },
        {
          path: '/menu',
          name: 'menu',
          component: () => import(/* webpackChunkName: "menu" */'./views/menu/Menu.vue')
        },
        {
          path: '/tooltip',
          name: 'tooltip',
          component: () => import(/* webpackChunkName: "tooltip" */'./views/tooltip/Tooltip.vue')
        },
        {
          path: '/poptip',
          name: 'poptip',
          component: () => import(/* webpackChunkName: "poptip" */'./views/poptip/Poptip.vue')
        },
        {
          path: '/image',
          name: 'iamge',
          component: () => import(/* webpackChunkName: "image" */'./views/image/Image.vue')
        },
        {
          path: '/steps',
          name: 'steps',
          component: () => import(/* webpackChunkName: "steps" */'./views/steps/Steps.vue')
        }
      ]
    },
    {
      path: '*',
      name: '404',
      component: {
        render (h) {
          return h('div', {
            staticClass: 'flex flex-main-center',
            attrs: {
              style: 'width:100%;font-size:32px'
            }
          }, '未找到哦')
        }
      }
    }
  ]
})
